package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * 说明:
 *
 * @author:SuZhongHe
 * @date:2023/3/2
 **/
public class IteratorDemo {
    public static void main(String[] args) {
        Collection c = new ArrayList();
        c.add("a");
        c.add("b");
        c.add("c");
        c.add("d");
        c.add("e");
        c.add("f");
        Iterator i = c.iterator();
        while (i.hasNext()) {
            String s = (String) i.next();
            System.out.println(s);
            if ("c".equals(s)) {
                i.remove();
            }
        }
        System.out.println(c);
    }
}

